package com.cyt.web.controller.work.antiepidemic;

import com.cyt.base.enums.BusinessType;
import com.cyt.base.enums.OperatorType;
import com.cyt.base.model.dto.ReturnResult;
import com.cyt.base.util.StringUtils;
import com.cyt.sys.aspect.BaseLog;
import com.cyt.web.controller.base.BaseController;
import com.cyt.work.antiepidemic.model.vo.AntiepidemicAreaVo;
import com.cyt.work.antiepidemic.service.AntiepidemicAreaService;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * e门通-省市区国标码控制层
 *
 * @author rong yuan
 * @date 2020-2-12 1:41:01
 */
@RestController
public class AntiepidemicAreaController extends BaseController {

    @Resource
    private AntiepidemicAreaService antiepidemicAreaService;

    /**
     * 统一跳转
     *
     * @param model 数据模型
     * @return Model
     * @author rong yuan
     * @date 2020-2-12 1:41:01
     */
    @RequestMapping("/work/antiepidemic/antiepidemicarea/*")
    public Model goPage(Model model) {
        return model;
    }

    /**
     * 分页查询
     *
     * @param antiepidemicAreaVo 接受参数对象
     * @param page               当前页面
     * @param limit              页面数量
     * @return ReturnResult
     * @author rong yuan
     * @date 2020-2-12 1:41:01
     */
    @BaseLog(module = "e门通", classz = "省市区国标码", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/antiepidemic/antiepidemicarea/page", method = RequestMethod.POST)
    public ReturnResult page(AntiepidemicAreaVo antiepidemicAreaVo, int page, int limit) {
        return antiepidemicAreaService.page(antiepidemicAreaVo, page, limit);
    }

    /**
     * 跳转添加或编辑界面
     *
     * @param id 主键
     * @return ReturnResult
     * @author rong yuan
     * @date 2020-2-12 1:41:01
     */
    @BaseLog(module = "e门通", classz = "省市区国标码", methods = "跳转添加或编辑界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/antiepidemic/antiepidemicarea/getEdit", method = RequestMethod.GET)
    public ModelAndView getEdit(String id) {
        ModelAndView view = new ModelAndView("/work/antiepidemic/antiepidemicarea/antiepidemicAreaEdit");
        if (StringUtils.isNotBlank(id)) {
            view.addObject(antiepidemicAreaService.selectByPrimaryKey(id));
        }
        return view;
    }

    /**
     * 保存或更新
     *
     * @param request            请求对象
     * @param antiepidemicAreaVo 接受参数对象
     * @return ReturnResult
     * @author rong yuan
     * @date 2020-2-12 1:41:01
     */
    @BaseLog(module = "e门通", classz = "省市区国标码", methods = "保存或更新对象", businessType = BusinessType.INSERT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/antiepidemic/antiepidemicarea/addOrUpdate", method = RequestMethod.POST)
    public ReturnResult addOrUpdate(HttpServletRequest request, AntiepidemicAreaVo antiepidemicAreaVo) {
        return antiepidemicAreaService.addOrUpdate(antiepidemicAreaVo, acceptCurrentUser(request));
    }

    /**
     * 根据条件逻辑删除
     *
     * @param request            请求对象
     * @param antiepidemicAreaVo 接受参数对象
     * @return ReturnResult
     * @author rong yuan
     * @date 2020-2-12 1:41:01
     */
    @BaseLog(module = "e门通", classz = "省市区国标码", methods = "逻辑删除对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/antiepidemic/antiepidemicarea/remove", method = RequestMethod.GET)
    public ReturnResult remove(HttpServletRequest request, AntiepidemicAreaVo antiepidemicAreaVo) {
        return antiepidemicAreaService.remove(antiepidemicAreaVo, acceptCurrentUser(request));
    }

    /**
     * 根据条件物理删除
     *
     * @param request            请求对象
     * @param antiepidemicAreaVo 接受参数对象
     * @return ReturnResult
     * @author rong yuan
     * @date 2020-2-12 1:41:01
     */
    @BaseLog(module = "e门通", classz = "省市区国标码", methods = "物理对象对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/antiepidemic/antiepidemicarea/delete", method = RequestMethod.GET)
    public ReturnResult delete(HttpServletRequest request, AntiepidemicAreaVo antiepidemicAreaVo) {
        return antiepidemicAreaService.delete(antiepidemicAreaVo, acceptCurrentUser(request));
    }
}